package com.grass.p019lv.activity;

import android.view.KeyEvent;
import android.webkit.WebView;
import android.widget.LinearLayout;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.grass.p019lv.AndroidInterface;
import com.grass.p019lv.databinding.ActivityWebViewLayoutBinding;
import com.gyf.immersionbar.ImmersionBar;
import com.just.agentweb.AgentWeb;
import com.just.agentweb.MiddlewareWebChromeBase;

/* renamed from: com.grass.lv.activity.WebViewActivity */
public class WebViewActivity extends BaseActivity<ActivityWebViewLayoutBinding> {
    private AgentWeb agentWeb;
    public String url;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return R.layout.activity_web_view_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityWebViewLayoutBinding) this.binding).toolbar).init();
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        ((ActivityWebViewLayoutBinding) this.binding).setClick(new OnClick());
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initData() {
        super.initData();
        openUrl(this.url);
    }

    @Override // androidx.appcompat.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        AgentWeb agentWeb2 = this.agentWeb;
        if (agentWeb2 == null || !agentWeb2.handleKeyEvent(i, keyEvent)) {
            return super.onKeyDown(i, keyEvent);
        }
        return true;
    }

    /* access modifiers changed from: protected */
    @Override // androidx.fragment.app.FragmentActivity
    public void onPause() {
        AgentWeb agentWeb2 = this.agentWeb;
        if (agentWeb2 != null) {
            agentWeb2.getWebLifeCycle().onPause();
        }
        super.onPause();
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        AgentWeb agentWeb2 = this.agentWeb;
        if (agentWeb2 != null) {
            agentWeb2.getWebLifeCycle().onDestroy();
        }
        super.onDestroy();
    }

    /* access modifiers changed from: protected */
    @Override // androidx.fragment.app.FragmentActivity
    public void onResume() {
        AgentWeb agentWeb2 = this.agentWeb;
        if (agentWeb2 != null) {
            agentWeb2.getWebLifeCycle().onResume();
        }
        super.onResume();
    }

    private void callJS() {
        this.agentWeb.getJsAccessEntrace().quickCallJs("callJS");
    }

    private void openUrl(String str) {
        this.agentWeb = AgentWeb.with(this).setAgentWebParent(((ActivityWebViewLayoutBinding) this.binding).linWeb, new LinearLayout.LayoutParams(-1, -1)).useDefaultIndicator().useMiddlewareWebChrome(new MiddlewareWebChromeBase() {
            /* class com.grass.p019lv.activity.WebViewActivity.C29551 */

            @Override // com.just.agentweb.WebChromeClientDelegate
            public void onReceivedTitle(WebView webView, String str) {
                super.onReceivedTitle(webView, str);
                ((ActivityWebViewLayoutBinding) WebViewActivity.this.binding).setTitle(str);
            }
        }).createAgentWeb().ready().mo26876go(str);
        callAndroid();
    }

    private void callAndroid() {
        this.agentWeb.getJsInterfaceHolder().addJavaObject("android", new AndroidInterface(this.agentWeb, this));
    }

    /* renamed from: com.grass.lv.activity.WebViewActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            WebViewActivity.this.finish();
        }
    }
}
